package com.zis.security.client;

import com.zis.starter.core.ResponseEntity;
import com.zis.system.model.GroupRes;
import com.zis.system.model.RoleRes;
import com.zis.system.model.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * Create by wangshen 2018/2/6
 */
@FeignClient(name = "sys-server")
public interface UserClient {

    /**
     * 根据用户名查询用户
     * @param loginName
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/select/username/{loginName}", method = RequestMethod.GET)
    ResponseEntity findByLoginName(@PathVariable("loginName") String loginName) throws Exception;

    /**
     * 修改密码
     * @param model
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/update", method = RequestMethod.POST)
    ResponseEntity update(@RequestBody User model) throws Exception;

    /**
     * 根据用户ID查询
     * @param id
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/select/{id}", method = RequestMethod.GET)
    ResponseEntity selectById(@PathVariable("id") String id) throws Exception;

    /**
     * 根据userId查询用户角色
     * @param userId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/user/select/role/{userId}", method = RequestMethod.GET)
    ResponseEntity findByUserId(@PathVariable("userId") String userId) throws Exception;


    /**
     * 根据角色ID查询角色资源
     * @param roleId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/role/res/list/{roleId}", method = RequestMethod.GET)
    List<RoleRes> findByRoleId(@PathVariable("roleId") String roleId) throws Exception;

    /**
     * 根据用户组ID查询
     * @param groupId
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/group/res/list/{groupId}", method = RequestMethod.GET)
    List<GroupRes> findByGroupId(@PathVariable("groupId") String groupId) throws Exception;
}